import UIKit

import SnapKit

@objcMembers
public class CATVistarPopView: CATBaseTipView {
    public lazy var iCompositedImgView: UIImageView = {
        let rasterization = UIImageView()
        rasterization.image = .caTimagePath("vhimg_vistar")
        return rasterization
    }()

    public lazy var nStickerButton: UIButton = {
        let bonus = UIButton(type: .custom)
        bonus.backgroundColor = UIColor(red: 175.0 / 255.0, green: 81.0 / 255.0, blue: 255.0 / 255.0, alpha: 1.0)
        bonus.layer.cornerRadius = 24
        bonus.layer.masksToBounds = true
        bonus.setTitle("I got it".localized(), for: .normal)
        bonus.setTitleColor(.white, for: .normal)
        bonus.addTarget(self, action: #selector(vhxqOnIgotitTap(sender:)), for: .touchUpInside)
        return bonus
    }()

    public lazy var jZigzagvineLabel: UILabel = {
        let forfeit = UILabel()
        forfeit.text = "The popularity of the platform is more than 80% female users".localized()
        forfeit.textColor = UIColor(red: 131.0 / 255.0, green: 130.0 / 255.0, blue: 134.0 / 255.0, alpha: 1.0)
        forfeit.font = .systemFont(ofSize: 14, weight: .regular)
        forfeit.numberOfLines = 2
        forfeit.textAlignment = .center
        return forfeit
    }()

    public lazy var qReactivatedLabel: UILabel = {
        let hygrometer = UILabel()
        hygrometer.text = "Vistar certification".localized()
        return hygrometer
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)
        configNutritionLzmaxSubViews()
    }

    required init?(coder: NSCoder) {
        super.init(coder: coder)
        configNutritionLzmaxSubViews()
    }

    private func configNutritionLzmaxSubViews() {
        // UI组件初始化
        vhbsView.addSubview(iCompositedImgView)
        iCompositedImgView.snp.makeConstraints { make in
            make.top.equalTo(24)
            make.centerX.equalTo(0)
            make.width.equalTo(56)
            make.height.equalTo(56)
        }

        vhbsView.addSubview(nStickerButton)
        nStickerButton.snp.makeConstraints { make in
            make.leading.equalTo(16)
            make.bottom.equalTo(-16)
            make.trailing.equalTo(-16)
            make.height.equalTo(48)
        }

        vhbsView.addSubview(jZigzagvineLabel)
        jZigzagvineLabel.snp.makeConstraints { make in
            make.leading.equalTo(16)
            make.bottom.equalTo(-24)
            make.trailing.equalTo(-16)
            make.height.equalTo(36)
        }

        vhbsView.addSubview(qReactivatedLabel)
        qReactivatedLabel.snp.makeConstraints { make in
            make.top.equalTo(24)
            make.centerX.equalTo(0)
            make.height.equalTo(20)
        }
    }

    @objc func vhxqOnIgotitTap(sender _: UIButton) {
        // 处理点击事件
    }

    public class func vhpopVistarPopView(vhdyV: UIView?) -> CATVistarPopView! {
        CATVistarPopView.vhbsRemove(String(describing: CATVistarPopView.self))
        let vhbsview = CATVistarPopView(frame: CGRect(x: 0, y: 0, width: VHbsWidth, height: VHbsHeigth))
        if vhdyV != nil {
            vhdyV!.addSubview(vhbsview)
        } else {
            vhbsWindow()?.addSubview(vhbsview)
        }
        return vhbsview
    }
}
